<?php
/*
 * @Author: wanzhengxin
 * @Date: 2021-04-01 21:58:34
 */


namespace app\index\controller;

use app\index\model\Appraise as AppraiseModel;  //引入model.

class Appraise extends Base
{
    public function get(){
        $res = new AppraiseModel();
        $data=$this->request->param();
        $r=$res->with("images,user")
            ->where('doc_id','=',$data['doc_id'])
            ->paginate(15);
        return $r;
    }
    public function all(){
        $res = new AppraiseModel();
        $data=$this->request->param();
        $r=$res->with("images,user")
            ->page($data['page'])
            ->limit(15)
            ->order('cTime desc')
            ->select();
        return $r;
    }
    public function update()
    {
        $data = $this->request->param();
        $res = new AppraiseModel();
        return $res->updateModel($data);
    }
    public function delete(){
        $data = $this->request->param();
        $res = new AppraiseModel();
        return $res->deleteModel($data);
    }
    public function save(){
        $res = new AppraiseModel();
        $data = $this->request->param();
         $r= $res->saveModel($data);
        return $r->id;
    }
    public function num(){
        $data = $this->request->param();
        $res =new AppraiseModel();
        return $res->where('foreign_id','=',$data['foreign_id'])
            ->where('a_class','=',$data['a_class'])->count();
    }
}